home *** CD-ROM | disk | FTP | other *** search
/ Web Star/List Star - Eve…he Ultimate Internet Site / StarNine Internet Pubisher (Web Star and List Star)(StarNine)(1995).iso / ListSTAR™ / Tools and Enhancments / Integrating ListSTAR⁄WebSTAR / Address-List-Editor.acgi < prev    next >
Encoding:
Text File  |  1995-08-02  |  8.9 KB  |  220 lines  |  [TEXT/ToyS]

  1. -----------------------------------------------------------------------
  2. -- StarNine Technologies, Inc., hereby disclaims all copyright interest
  3. -- in the following source code written by Joshua D. Baer
  4. -- based on cgi shell by Jon Wiederspan (jonwd@tjp.washington.edu).
  5. -- 
  6. -- This source code is free and has been placed into the public domain.
  7. -- You can redistribute it, modify it (including these comments) and/or
  8. -- create derivative works from it as you see fit.
  9. --
  10. -- This source code is made available in the hope that it will be useful,
  11. -- but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. -----------------------------------------------------------------------
  14. --STUFF YOU WOULD WANT TO CUSTOMIZE (until the "END OF CUSTOMIZABLE STUFF" line)
  15. --
  16. --this is the file specification of the backround file to use property background : "<BODY BACKGROUND=background.gif>"
  17. --these contain information about the adminstrator for the footers of HTML pages generated
  18. property adminname : "Administrator Name"
  19. property adminaddress : "adminstrator@yourserver.yourdomain"
  20. property adminurl : "yourhomepage"
  21. property background : "<BODY BACKGROUND=background.gif>"
  22.  
  23. (*
  24. ** This routine checks the listname value passed from the HTML
  25. ** form and returns the respective servicename.  This is necessary
  26. ** in order to uniquely qualify the address list passed to
  27. ** ListSTAR.
  28. **
  29. ** When editing, the values on the left (in the
  30. ** if...then part) are the checkbox names in the HTML form.  The
  31. ** values on the right (after the set...to part) are the names of
  32. ** the service associated with each list.  Make sure both of these
  33. ** names are spelled exactly. After this is done scroll down to Comment B:
  34. ** which will instruct you to input your Address List Name.
  35. *)
  36.  
  37. on s9setservice(listname)
  38.     if listname is "Test List 1" then set listname to "Test 1 Service Name"
  39.     if listname is "Test List 2" then set listname to "Test 2 Service Name"
  40.     if listname is "Test List 3" then set listname to "Test 3 Service Name"
  41.     if listname is "Test List 4" then set listname to "Test 4 Service Name"
  42.     return listname
  43. end s9setservice
  44.  
  45. (*
  46. ** This just returns the footer applied to the bottom of all HTML
  47. ** documents.  Customize it at will, just be sure to end it with
  48. ** "</BODY></HTML>".
  49. *)
  50. on s9footer()
  51.     return "<HR SIZE=2>" & ¬
  52.         "<H4>Return to the <A HREF=liststar-admin.html>ListSTAR Administration form</A></H4><HR SIZE=4>" & ¬
  53.         (current date) & "<BR><A HREF=" & adminurl & ">" & adminname & ¬
  54.         "</A><BR><A HREF=mailto:" & adminaddress & "><ADDRESS>" & ¬
  55.         adminaddress & "</ADDRESS></A></BODY></HTML>"
  56. end s9footer
  57. --END OF CUSTOMIZABLE STUFF
  58.  
  59.  
  60. property crlf : (ASCII character 13) & (ASCII character 10)
  61. property http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: WebSTAR/1.0 ID/ACGI" & crlf & ¬
  62.     "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf
  63. property idletime : 1800
  64. property datestamp : 0
  65. property AlreadyInList : 107
  66. property NotInList : 105
  67. set datestamp to current date
  68.  
  69.  
  70. on s9error105(thename, thelist)
  71.     return "<H4>Sorry, " & thename & " is not a subscriber of the " & thelist & ".</H4>"
  72. end s9error105
  73.  
  74.  
  75. on s9error107(thename, thelist)
  76.     return "<H4>Sorry, " & thename & " is already a subscriber of the " & thelist & ".</H4>"
  77. end s9error107
  78.  
  79.  
  80.  
  81. on s9subcheck(return_page, thename, theaddress, listaction, thelists)
  82.     repeat with thelist in thelists
  83.         set return_page to return_page & thename & " <I>(" & theaddress & ")</I> is "
  84.         set servicename to s9setservice(thelist)
  85.         tell application "ListSTAR Server"
  86.             if ((StarNine Is thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress) is 0) then
  87.                 set return_page to return_page & "<B>not</B> "
  88.             end if
  89.         end tell
  90.         set return_page to return_page & "a member of the " & thelist & ".<P>" & return
  91.     end repeat
  92.     return return_page
  93. end s9subcheck
  94.  
  95.  
  96.  
  97. on s9subscribe(return_page, thename, theaddress, listaction, thelists)
  98.     repeat with thelist in thelists
  99.         set servicename to s9setservice(thelist)
  100.         try
  101.             tell application "ListSTAR Server" to StarNine Subscribe thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress
  102.             set return_page to return_page & thename & " <I>(" & theaddress & ")</I> has been <B>subscribed</B> to the " & thelist & ".<P>" & return
  103.         on error errMsg number errNum
  104.             if errNum is AlreadyInList then
  105.                 set return_page to return_page & s9error107(thename, thelist)
  106.             else
  107.                 error errMsg number errNum
  108.             end if
  109.         end try
  110.     end repeat
  111.     return return_page
  112. end s9subscribe
  113.  
  114.  
  115.  
  116. on s9unsubscribe(return_page, thename, theaddress, listaction, thelists)
  117.     repeat with thelist in thelists
  118.         set servicename to s9setservice(thelist)
  119.         try
  120.             tell application "ListSTAR Server" to StarNine Unsubscribe thelist Service servicename addresses {FreeFormName:thename, EMailAddress:theaddress} as StarNineAddress
  121.             set return_page to return_page & thename & " <I>(" & theaddress & ")</I> has been <B>unsubscribed</B> from the " & thelist & ".<P>" & return
  122.         on error errMsg number errNum
  123.             if errNum is NotInList then
  124.                 set return_page to return_page & s9error105(thename, thelist)
  125.             else
  126.                 error errMsg number errNum
  127.             end if
  128.         end try
  129.     end repeat
  130.     return return_page
  131. end s9unsubscribe
  132.  
  133.  
  134.  
  135. on «event WWWΩsdoc» path_args ¬
  136.     given «class kfor»:http_search_args, «class post»:post_args, «class meth»:method, «class addr»:client_address, «class user»:username, «class pass»:password, «class frmu»:from_user, «class svnm»:server_name, «class svpt»:server_port, «class scnm»:script_name, «class ctyp»:content_type, «class refr»:referer, «class Agnt»:user_agent, «class Kact»:action, «class Kapt»:action_path, «class Kcip»:client_ip, «class Kfrq»:full_request
  137.     try
  138.         set thelists to {}
  139.         set datestamp to current date
  140.         set return_page to http_10_header & "<HTML><HEAD><TITLE>ListSTAR Admin Results</TITLE></HEAD>" & background & "<BODY><H1>ListSTAR Admin Results</H1>" & return & return
  141.         
  142.         set postarglist to tokenize (dePlus post_args) with delimiters {"&"}
  143.         
  144.         set oldDelim to AppleScript's text item delimiters
  145.         set AppleScript's text item delimiters to {"="}
  146.         --the quoted part of each "if...then" statement should contain the "name" of a field in the referring form.
  147.         repeat with currpostarg in postarglist
  148.             set currname to first text item of currpostarg
  149.             if currname = "name" then
  150.                 set myname to (Decode URL (last text item of currpostarg))
  151.             else if currname = "address" then
  152.                 set useraddress to (Decode URL (last text item of currpostarg))
  153.             else if currname = "listAction" then
  154.                 set listaction to (Decode URL (last text item of currpostarg))
  155.                 
  156. --COMMENT B: modify the following to accomodate the number of lists
  157. --all you need to do is copy the first two lines, and change the quoted 
  158. --statement to the list name
  159.                 
  160.             else if currname = "Test List 1" then
  161.                 set thelists to thelists & {currname}
  162.             else if currname = "Test List 2" then
  163.                 set thelists to thelists & {currname}
  164.             else if currname = "Test List 3" then
  165.                 set thelists to thelists & {currname}
  166.             else if currname = "Test List 4" then
  167.                 set thelists to thelists & {currname}
  168.             else if currname = "S" then
  169.                 -- ignore it.  That's the Submit button.
  170.             else
  171.                 error ("Unknown variable in post_args: " & currname) number 100
  172.             end if
  173.         end repeat
  174.         
  175.         set AppleScript's text item delimiters to oldDelim
  176.         
  177.         if thelists is {} then
  178.             set return_page to return_page & "<H3>No address lists were selected.  Please try again.</H3>" & return
  179.         else if useraddress is "" then
  180.             set return_page to return_page & "<H3>You must fill in an email address  Please try again.</H3>" & return
  181.         else if listaction is "Subscribe Check" then
  182.             set return_page to s9subcheck(return_page, myname, useraddress, listaction, thelists)
  183.         else if listaction is "Subscribe" then
  184.             set return_page to s9subscribe(return_page, myname, useraddress, listaction, thelists)
  185.         else if listaction is "Unsubscribe" then
  186.             set return_page to s9unsubscribe(return_page, myname, useraddress, listaction, thelists)
  187.         else
  188.             set return_page to return_page & "An unknown action was requested: " & listaction & "<BR>" & return
  189.         end if
  190.         
  191.         set return_page to return_page & s9footer()
  192.         return return_page
  193.         
  194.     on error errMsg number errNum
  195.         set return_page to http_10_header ¬
  196.             & "<HTML><HEAD><TITLE>Error Page</TITLE></HEAD>" & "<BODY><H1>Error Encountered!</H1>" & return ¬
  197.             & "An error was encountered while trying to run this script." & return
  198.         set return_page to return_page ¬
  199.             & "<H3>Error Message</H3>" & return & errMsg & return ¬
  200.             & "<H3>Error Number</H3>" & return & errNum & return ¬
  201.             & "<H3>Date</H3>" & return & (current date) & return
  202.         set return_page to return_page ¬
  203.             & "<HR>Please notify " & adminname & "at " & ¬
  204.             "<A HREF=\"mailto:" & adminaddress & "\">" & adminaddress & "</A>" & " of this error." & "</BODY></HTML>"
  205.         return return_page
  206.     end try
  207. end «event WWWΩsdoc»
  208.  
  209. on idle
  210.     if (current date) > (datestamp + idletime) then
  211.         quit
  212.     end if
  213.     return 5
  214. end idle
  215.  
  216. on quit
  217.     continue quit
  218. end quit
  219.  
  220.